package cn.edu.laud.sany.utils;

/**
 * 时间转化函数
 * 
 * @author zhongyu
 * 
 */
public class TimeUtils
{
	/**
	 * 纳秒到 时分秒毫秒的转化显示
	 * 
	 * @param nanoSecond
	 * @return
	 */
	public static String nanoSecondToString(long nanoSecond)
	{
		StringBuilder sb = new StringBuilder(10);
		nanoSecond /= 1000000000;
		int sec = 0, min = 0;
		long hour = 0;
		if (nanoSecond != 0)
		{
			sec = (int) (nanoSecond % 60);
			nanoSecond /= 60;
			if (nanoSecond != 0)
			{
				min = (int) (nanoSecond % 60);
				nanoSecond /= 60;
				if (nanoSecond != 0)
				{
					hour = (int) (nanoSecond % 24);
					nanoSecond /= 24;
				}
				
			}
		}
		
		sb.append(hour);
		sb.append(":");
		if (min < 10)
		{
			sb.append("0");
		}
		sb.append(min);
		sb.append(":");
		if (sec < 10)
		{
			sb.append("0");
		}
		sb.append(sec);
		
		return sb.toString();
	}
	
}
